<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" />
    <title>修改资源_资源共享平台</title>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <link rel="stylesheet" href="/css/style.css"/>
</head>
<body>
<div th:include="common/header" class="header-wrapper"></div>
<div class="container-wrapper">
    <div th:include="common/menu" class="menu-left"></div>
    <div class="menu-right">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>修改资源</legend>
        </fieldset>
        <div style="margin-left: 10px">
            <p style="margin: 20px 0 20px 30px;">
                发帖规范，利于seo，必看：<br/>
                1、资源标题搞成类似xxx视频下载、xxxpdf下载；<br/>
                2、必须要有图片和文字目录有利于seo优化；<br/>
                3、图片上传前把图片名称改成资源的标题，这样上传的图片有一个alt属性，有利于seo优化；<br/>
                4、文字目录的话，网页版的百度云可以直接复制下目录。
            </p>
            <form class="layui-form" action="/res/update" method="post">
                <input type="hidden" name="id" th:value="${res.id}" />
                <div class="layui-form-item">
                    <label class="layui-form-label">资源名称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" th:value="${res.name}" autocomplete="off" placeholder="请输入资源名称" class="layui-input" lay-verify="required" lay-reqText="请输入资源名称" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资源类别：</label>
                    <div class="layui-input-inline">
                        <select name="resType.id" lay-verify="required" lay-reqText="请选择资源类别">
                            <option value="">请选择资源类别</option>
                            <option th:each="resType:${application.allResTypeList}" th:value="${resType.id}" th:text="${resType.name}" th:selected="${resType.id==res.resType.id}"></option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资源描述：</label>
                    <div class="layui-input-block">
                        <textarea id="content" name="content" class="layui-textarea" lay-verify="content" style="display: none;" th:utext="${res.content}"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">分享资源：</label>
                        <div class="layui-input-inline" style="width: 400px">
                            <input type="text" name="downloadUrl" th:value="${res.downloadUrl}" autocomplete="off" placeholder="请输入百度云分享地址" class="layui-input" lay-verify="url" lay-reqText="请输入百度云分享地址" />
                        </div>
                        <div class="layui-input-inline" style="width: 100px">
                            <input type="text" name="downloadPass" th:value="${res.downloadPass}" autocomplete="off" placeholder="请输入密码" class="layui-input" lay-verify="required" lay-reqText="请输入密码" />
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">积分设置：</label>
                    <div class="layui-input-inline" style="width: 120px">
                        <select name="points" th:field="*{res.points}" lay-verify="required" lay-reqText="请选择积分">
                            <option value="">请选择积分</option>
                            <option value="0">0个积分</option>
                            <option value="1">1个积分</option>
                            <option value="2">2个积分</option>
                            <option value="3">3个积分</option>
                            <option value="4">4个积分</option>
                            <option value="5">5个积分</option>
                            <option value="6">6个积分</option>
                            <option value="7">7个积分</option>
                            <option value="8">8个积分</option>
                            <option value="9">9个积分</option>
                            <option value="10">10个积分</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="*">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div th:include="common/link" class="wrapper"></div>
<div th:include="common/footer" class="footer-wrapper"></div>

<script src="/layui/layui.js"></script>
<script src="/js/common.js"></script>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    layui.use(['layer', 'form', 'layedit', 'element'], function () {
        let $ = layui.jquery,
            layer = layui.layer,
            form = layui.form,
            layedit = layui.layedit;

        let index = layedit.build('content', {
            uploadImage: {
                url: '/res/uploadImage',
                type: 'post'
            }
        });

        // 监听提交
        form.on('submit(*)', function (data) {
            let content = layedit.getContent(index);
            if (content == "") {
                layer.msg("请输入资源描述！");
                return false;
            }
            $("#content").val(content);
            return true;
        });
    });
    /*]]>*/
</script>
</body>
</html>